/**数据库 */
const mongoose = require('mongoose')
mongoose.connect('mongodb://127.0.0.1:27017/backend', (err) => {
  if (err === null) {
    console.log('mongodb数据库连接成功！')
  }
})
const UserSchema = mongoose.Schema({
  username: {
    type: String,
    required: true,
    unique: true,
    minlength: 2
  },
  sex: {
    type: String,
    default:'保密'
  },
  age:{
    type:Number,
    default:0
  },
  phone:{
    type: String,
    required: true,
    unique: true,
    minlength: 11,
    maxlength: 11
  }
})
const membersModel = mongoose.model('Member', UserSchema, 'members')
module.exports = membersModel
/***数据库结束 */